﻿using AutoMapper;
using JavaDevToys.Rcl.AutoMapper;
using JavaDevToys.Rcl.Entities;
using JavaDevToys.Rcl.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace JavaDevToys.Rcl.AutoMapper
{
    public class EntityProfile : Profile
    {
        public EntityProfile()
        {
            CreateMap<DevtoysCustomcodeGroup, CustomJavaCodeGroup>()
                .ForMember(a=>a.DevtoysCustomCodeGroupId,b=>b.MapFrom(src=> src.DevtoysCustomcodeGroupId));
            CreateMap<CustomJavaCodeGroup, DevtoysCustomcodeGroup>()
                .ForMember(a => a.DevtoysCustomcodeGroupId, b => b.MapFrom(src => src.DevtoysCustomCodeGroupId));
            CreateMap<DevtoysCustomcode, CustomJavaCode>()
                .ForMember(a=>a.CustomCodeValue,b=>b.MapFrom(src=>src.CustomcodeCode))
                .ForMember(a => a.CustomCodeName, b => b.MapFrom(src => src.CustomcodeName))
                .ForMember(a => a.DevtoysCustomCodeGroupId, b => b.MapFrom(src => src.DevtoysCustomcodeGroupId))
                .ForMember(a => a.CustomCodeDesc, b => b.MapFrom(src => src.CustomcodeDesc));
            CreateMap<CustomJavaCode, DevtoysCustomcode>()
                .ForMember(a => a.CustomcodeCode, b => b.MapFrom(src => src.CustomCodeValue))
                .ForMember(a => a.CustomcodeName, b => b.MapFrom(src => src.CustomCodeName))
                .ForMember(a => a.DevtoysCustomcodeGroupId, b => b.MapFrom(src => src.DevtoysCustomCodeGroupId))
                .ForMember(a => a.CustomcodeDesc, b => b.MapFrom(src => src.CustomCodeDesc));
        }
    }
}

namespace Microsoft.Extensions.DependencyInjection
{
    public static class EntityProfileExtension
    {
        public static IServiceCollection AddEntityAutoMapper(this IServiceCollection services)
        {
            return services.AddAutoMapper(typeof(EntityProfile));
        }
    }
}

